package com.example.springdatajpa;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.RequestHandler;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import javax.swing.text.Document;
import java.util.function.Predicate;

/**
 * Swgger2 配置类
 */

@Configuration
@EnableSwagger2
public class Swgger2 {

    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2)
            .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.example.springdatajpa"))
                .paths(PathSelectors.any())
                .build();
    }

    public ApiInfo apiInfo(){
        Contact contact = new Contact("朱殿辉","null","969175052@qq.com");

        return new ApiInfoBuilder()
                .title("SpringDataJpa 的使用")
                .description("数据持久层的快速开发API")
                .termsOfServiceUrl("https://spring.io/projects/spring-data-jpa")
                .contact(contact)
                .version("1.0")
                .build();
    }

}
